using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Generic;

public partial class upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		try
		{
			// Get the data
			HttpPostedFile jpeg_image_upload = Request.Files["Filedata"];

			// Retrieve the uploaded image
            string sPath = Server.MapPath("../content/Galery/");
            string sFileName = "slider_"+Helper.GenerateUniqueFileName() + "." + jpeg_image_upload.FileName.Split('.')[1];
            jpeg_image_upload.SaveAs(sPath + sFileName);

            //        //insertIntoDb
            Dal.arParams.Clear();
            Dal.arParams.Add(0);//WorkID
            Dal.arParams.Add(sFileName);
            Dal.ExecuteDBsp("Admin_UploadImage", Dal.arParams);
		}
		catch
		{
			// If any kind of error occurs return a 500 Internal Server error
			Response.StatusCode = 500;
			Response.Write("An error occured");
			Response.End();
		}
		finally
		{
			Response.End();
		}
	}
    ////Image name template
    //private string GenerateUniqueFileName()
    //{
    //    return String.Format("{0}{1}{2}{3}{4}{5}",
    //                          DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day,
    //                          DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Millisecond);
    //}//GenerateUniqueFileName()
}
